<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ page import="org.springframework.context.ApplicationContext" %>
<%@ page import="com.sz.common.ICommonDAO" %>


<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

String style0 = "text-align:center;font-size: 12px;";
String style1 = "text-align:right;font-size: 12px;";
String style2 = "width: 100px";
String style3 = "text-align:left;font-size: 12px;width: 100px";









%>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		
		<base href="<%=basePath%>">

		<title>坐席公告</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="announce_seating">
		<meta http-equiv="description" content="坐席公告">
		
		<style type="text/css"> 
			@import "js/tableview/TableView.css";
    	</style>
	</head>
	
	<body>		
		<script type="text/javascript" src="js/jquery.js"></script>
		<script type="text/javascript" src="js/tableview/SortView.js"></script>
		<script type="text/javascript" src="js/tableview/PagerView.js"></script>
		<script type="text/javascript" src="js/tableview/TableView.js"></script>
		<script type="text/javascript" src="js/tableview/SelectorView.js"></script>
		<script type="text/javascript" src="js/tableview/PaperView.js"></script>
		<script type="text/javascript" src="js/utility.js"></script>
		<script type="text/javascript" src="js/calendar.js"></script>
	
	  	<form name="seating_query_form" style="width: 100%"> 
	  	 <table style="width: 100%" >	  	 
		  	<tr>
			  	<td style="<%=style1%>">开始时间</td>
			  	<td style="<%=style3%>">
					<input type="text" id="begin_time_1" name="begin_time_1" style="<%=style2%>" onclick="calendar.show(this)" >	
			  	</td>
			  	<td style="<%=style0%>">到</td>
			  	<td style="<%=style3%>">
					<input type="text" id="begin_time_2" name="begin_time_2" style="<%=style2%>" onclick="calendar.show(this)" >	
			  	</td>
			  	
			  	<td style="<%=style1%>">结束时间</td>
			  	<td style="<%=style3%>">
					<input type="text" id="end_time_1" name="end_time_1" style="<%=style2%>" onclick="calendar.show(this)" >	
			  	</td>
			  	<td style="<%=style0%>">到</td>
			  	<td style="<%=style3%>">
					<input type="text" id="end_time_2" name="end_time_2" style="<%=style2%>" onclick="calendar.show(this)" >	
			  	</td> 	
	
			  	<td style="<%=style1%>">发布时间</td>
			  	<td style="<%=style3%>">
					<input type="text" id="create_time_1" name="create_time_1" style="<%=style2%>" onclick="calendar.show(this)" >	
			  	</td>
			  	<td style="<%=style0%>">到</td>
			  	<td style="<%=style3%>">
					<input type="text" id="create_time_2" name="create_time_2" style="<%=style2%>" onclick="calendar.show(this)" >	
			  	</td> 				 
		  	</tr>		  	
		  	
		  	<tr>
		  	  <td style="<%=style1%>">公告标题</td>
		  	  <td colspan="3">
		  	  	<input type="text" id="title" name="title" >
		  	  </td>
		  	  
		  	  <td style="<%=style1%>">状态</td>
		  	  <td colspan="6">
		  		<select id="state" name="state"> 
			  		<option value="">请选择</option> 
			  		<option value="1">有效</option> 
			  		<option value="0">无效</option> 
		  		</select>
		  	  </td>
  			  <td colspan="1" style="<%=style1%>">	
  			  	<input type="button"  value="查询" onclick="onQuery()"> 	  	  	
		  	  	<input type="button"  value="添加" onclick="onAdd()"> 
		  	  </td>
		  	</tr>
	  	</table>	  	
  	</form> 
  	

 	<table width="100%">
  		<tr>
	  		<td>
			  	<div id="table_div" style= "width: 100%"></div>
				<div id="pager"></div>
			</td>
		</tr>
  	</table>

  	
  	<SCRIPT LANGUAGE="JavaScript">
  	
  		var numPerPage = 10; //每页行数
		var paramValue = "";
		var methodCount = "queryAnnounce_seatingCount";
		var methodPage = "queryAnnounce_seatingPage";
		
		var table = new TableView('table_div');
		table.header = {
			TITLE			: '公告标题',
			BEGIN_TIME		: '开始时间',
			END_TIME		: '结束时间',
			CREATE_MANAGER	: '发布人',
			CREATE_TIME 	: '发布时间',
			STATE			: '状态',
			OPERATE			: '操作'		
		};		
		table.customDefine = {
			TITLE			: '',
			BEGIN_TIME		: '',
			END_TIME		: '',
			CREATE_MANAGER	: '',
			CREATE_TIME	 	: '',
			STATE			: '',
			OPERATE			: ''		
		};
				
		table.dataKey = 'ANNOUNCE_SEATING_ID';
		table.count = false;
		table.title = false;
		table.display.filter = false;
		table.display.pager = false;
		table.display.multiple = false;
		table.pager.size = numPerPage;

		var pager = new PagerView('pager');
		pager.onclick = onPagerClick;
		pager.itemCount = 0;
		pager.size = numPerPage;
		
		table.render();
		pager.render();

		function query(pageNO, returnCount) {
  	  		var begin = (pageNO-1) * numPerPage + 1;
  	  		var end = pageNO * numPerPage;
  	  		var mc = returnCount==true ? methodCount : "";
  	  		var date = {
  	  			BEAN_METHOD 	: "AnnounceBMO.queryAnnounce_seating",
  	  			PARAM_CLASS 	: "java.util.Map",
  	    	  	PARAM_VALUE 	: paramValue,
  	    	  	METHOD_COUNT 	: mc, //为空则不返回记录数
  	    	  	METHOD_PAGE 	: methodPage, //为空则不分页
  	    	  	PAGE_BEGIN 		: begin, //仅在METHOD_PAGE不为空时使用
  	    	  	PAGE_END 		: end
  	  	    };
  	  		$.ajax({
				type: "POST",
				url: "query.exec",
				//data: {id:'123'},
				data: date,
				datatype:"json",
				success: query_success,
				error: show_error
  	  		});
  	  	}
  	  	
  	  	function onPagerClick(pageNO) {
  			queryBusiness(pageNO, "FLASE");
  		}
  	  	
  	  	//刷新当前页
  		function refreshCurrentPage() {
  			queryBusiness(pager.index, "FLASE");
  		}
  			
  		function onQuery() {
  			//先检查输入
  			var begin_time_1 = document.getElementById("begin_time_1").value;
  			var begin_time_2 = document.getElementById("begin_time_2").value;
  			var end_time_1 = document.getElementById("end_time_1").value;
  			var end_time_2 = document.getElementById("end_time_2").value;
  			var create_time_1 = document.getElementById("create_time_1").value;
  			var create_time_2 = document.getElementById("create_time_2").value;
  			var title = document.getElementById("title").value;
  			var state = document.getElementById("state").value;
  			
  			
  			

  			
  			//生成查询参数paramValue
  			var tmp;
			paramValue = "{";
			
			paramValue += " BEGIN_TIME_1:'" + begin_time_1; 
			paramValue += "'";
			paramValue += ",";
			
			paramValue += " BEGIN_TIME_2:'" + begin_time_2; 
			paramValue += "'";
			paramValue += ",";
			
			paramValue += " END_TIME_1:'" + end_time_1; 
			paramValue += "'";
			paramValue += ","; 			
			
			paramValue += " END_TIME_2:'" + end_time_2; 
			paramValue += "'";
			paramValue += ","; 
			
			paramValue += " CREATE_TIME_1:'" + create_time_1; 
			paramValue += "'";
			paramValue += ","; 
			
			paramValue += " CREATE_TIME_2:'" + create_time_2; 
			paramValue += "'";
			paramValue += ","; 	
			
			paramValue += " TITLE:'" + title; 
			paramValue += "'";
			paramValue += ","; 	
			
			paramValue += " STATE:'" + state; 
			paramValue += "'";		
  			  			
  			paramValue += "}";  			
  			
  			pager.index = 1;
  	  		query(1, true);
  		}
  		
  		function query_success(data) {
  	  		var jdata = eval("(" + data + ")");
  	  		if(jdata.COUNT != null) { //有记录数返回  	  	  		
  	  	  		pager.itemCount = jdata.COUNT;
  	  	  		pager.size = numPerPage;  	  	  		
  	  	  		pager.render();
  	  		} 
		   var array = eval(jdata.LIST);
		   for(var i = 0; i < array.length; ++i) {
		   		url = "<input type=\"button\" value=\"修改\" onclick=\"onUpt('";
		   		url += array[i].ANNOUNCE_SEATING_ID;
		   		url += "')\" />";
				url += "<input type=\"button\" value=\"删除\" onclick=\"onDel('";
		   		url += array[i].ANNOUNCE_SEATING_ID;		  
		   		url += "')\" />";
		   		array[i].OPERATE = url;
		   }
		   table.clear();
		   table.addRange(array);
		}
  		function show_error(data) {
  			var err = "操作失败！\n";
  			err += "status：" + data.status + "\n";
  			err += "statusText：" + data.statusText;
  	  		alert(err);
 		}
 		
 		function onBusinessDetail(business_id) {
 			alert(business_id);
 		}
 		function onUpt(id){
		 	url = "<%=path%>";
  			url += "/announce/uptAnnounce_seating.do?ANNOUNCE_SEATING_ID="+id+"";  			
  			var param = "status:no;scroll:no;dialogWidth:800px;dialogHeight:600px";
			window.showModalDialog(url, window, param);
 		}
 		function onDel(id) {
 			if (confirm('您确定要删除吗?')) {
				var param = "{ANNOUNCE_SEATING_ID:";
	  			param += "'"+id+"'";
	  			param += "}";

	  			$.ajax({
					type: "POST",
					url: "announce/delAnnounceSeating.ajax",
					data: {PARAM:param, OPERATE_TYPE:"DEL", ANNOUNCE_TYPE:"SEATING", RETURNTYPE:'MESSAGE'},
					datatype:"json",
					success: okSuccess,
					error: show_error
	  	  		});
  	  		}
 		}
 		
 		function okSuccess(data) {
  	  		alert(data);
  	  		onQuery();  	  		
 		}
 		
 		function onAdd() {			
 			url = "<%=path%>";
  			url += "/announce/addAnnounce_seating.do?OPERATE_TYPE=ADD&ANNOUNCE_TYPE=SEATING";  			
  			var param = "status:no;scroll:no;dialogWidth:800px;dialogHeight:600px";
			window.showModalDialog(url, window, param);
 		}
  	
  	</SCRIPT>
	</body>
</html>
